#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main (int argc, char* argv[])
{
    string line;
    int numPerda = 0;

    if (argc != 2)
        cout << "Usage: ./perdaPacotes TraceFileGerado\n";

    ifstream inFile(argv[1]); 
    ofstream outFile("qtPerdaPacotes.txt", ios::app); // ios::app = APPEND
    if (inFile.is_open() && outFile.is_open())
    {
        while ( inFile.good() )
        {
            getline ( inFile, line );
            if ( line[0] == 'd' )
                numPerda++;
        }
        outFile << numPerda << endl;
    }

    inFile.close();
    return 0;
}

